package day17;

import java.util.*;

/**
 * 杨辉三角变形
 */
public class Solution {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()) {
            int numRow = scanner.nextInt();
            if(numRow == 1 || numRow == 2){
                System.out.println(-1);
            }else if(numRow % 4 == 3 || numRow % 4 == 1){
                System.out.println(2);
            } else if(numRow % 4 == 0){
                System.out.println(3);
                continue;
            }
            else if(numRow % 4 == 2){
                System.out.println(4);
                continue;
            }
        }
    }
}
